package com.jingle.tutorial;

import java.util.*;

import com.jingle.tutorial.other.CarMaster;

public class CarAttributeCache {
	private static Random rand;
	private static final String[] makes = {"Ford", "Toyota", "Chevy", "Jeep", "Dodge"};
	private static final String[] fords = {"Focus", "F150", "Taurus", "Mustang", "Explorer"};
	private static final String[] toyotas = {"Camry", "Corolla", "Avalon", "Yaris", "Prius"};
	private static final String[] chevys = {"Cavalier", "Cobalt", "Avalanche", "Tahoe", "Suburban"};
	private static final String[] jeeps = {"Cherokee", "Grand Laredo", "Wrangler", "Liberty", "Compass"};
	private static final String[] dodges = {"Ram", "Neon", "Durango", "Charger", "Challenger"};
	private static final String[] colors = {"Black", "White", "Red", "Blue", "Silver"};
	private static final String[] pimpLevelArray = { CarMaster.PIMP_LEVEL_LOW, CarMaster.PIMP_LEVEL_MEDIUM, 
													  CarMaster.PIMP_LEVEL_HIGH, CarMaster.PIMP_LEVEL_REALLY_HIGH, 
													  CarMaster.PIMP_LEVEL_PIMPIN };
	public static Random getRand() {
		return rand;
	}

	public static void setRand(Random rand) {
		CarAttributeCache.rand = rand;
	}

	public static String[] getMakes() {
		return makes;
	}

	public static String[] getFords() {
		return fords;
	}

	public static String[] getToyotas() {
		return toyotas;
	}

	public static String[] getChevys() {
		return chevys;
	}

	public static String[] getJeeps() {
		return jeeps;
	}

	public static String[] getDodges() {
		return dodges;
	}

	public static String[] getColors() {
		return colors;
	}

	public static String[] getPimplevelarray() {
		return pimpLevelArray;
	}
	private static CarAttributeCache instance = null;
	private Map<String, String[]> carMap;

	// Create a private map with attributes as the keys and lists of possible
	// values as the values
	// e.g. TreeMap<String, ArrayList<String>>

	// We're using a singleton model here, so the constructor is private
	private CarAttributeCache() {
		init();
	}

	// Use this method to get the cached class
	synchronized public static CarAttributeCache instance() {
		if (instance == null) {
			instance = new CarAttributeCache();
		}
		return instance;
	}

	private void init() {
		carMap = new TreeMap<String, String[]>();
		carMap.put("Makes", getMakes());
		carMap.put("Fords", getFords());
		carMap.put("Toyotas", getToyotas());
		carMap.put("Chevys", getChevys());
		carMap.put("Jeeps", getJeeps());
		carMap.put("Dodges", getDodges());
		carMap.put("Colors", getColors());
		carMap.put("PimpLevel", getPimplevelarray());
	}

	public Map<String, String[]> getCarMap() {
		return carMap;
	}

	public void setCarMap(Map<String, String[]> carMap) {
		this.carMap = carMap;
	}

}
